from logic import logic

class mediator_fake :
    def __init__ ( self ) :
        self . _call_history = [ ]
    def hide_copy_menu ( self ) :
        self . _call_history += [ mediator_fake . hide_copy_menu ]
    def hide_creation_menu ( self ) :
        self . _call_history += [ mediator_fake . hide_creation_menu ]
    def hide_edit_menu ( self ) :
        self . _call_history += [ mediator_fake . hide_edit_menu ]
    def hide_editor ( self ) :
        self . _call_history += [ mediator_fake . hide_editor ]
    def hide_main_menu ( self ) :
        self . _call_history += [ mediator_fake . hide_main_menu ]
    def hide_open_menu ( self ) :
        self . _call_history += [ mediator_fake . hide_open_menu ]
    def hide_rename_menu ( self ) :
        self . _call_history += [ mediator_fake . hide_rename_menu ]
    def hide_save_as_menu ( self ) :
        self . _call_history += [ mediator_fake . hide_save_as_menu ]
    def hide_welcome ( self ) :
        self . _call_history += [ mediator_fake . hide_welcome ]
    def quit_application ( self ) :
        self . _call_history += [ mediator_fake . quit_application ]
    def run_main_loop ( self ) :
        self . _call_history += [ mediator_fake . run_main_loop ]
    def save_as_knowledge_base_in_editor ( self , base_name ) :
        self . _call_history += [ [ mediator_fake . save_as_knowledge_base_in_editor , base_name ] ]
    def save_knowledge_base_in_editor ( self ) :
        self . _call_history += [ mediator_fake . save_knowledge_base_in_editor ]
    def show_copy_menu ( self ) :
        self . _call_history += [ mediator_fake . show_copy_menu ]
    def show_creation_menu ( self ) :
        self . _call_history += [ mediator_fake . show_creation_menu ]
    def show_edit_menu ( self ) :
        self . _call_history += [ mediator_fake . show_edit_menu ]
    def show_editor ( self ) :
        self . _call_history += [ mediator_fake . show_editor ]
    def show_main_menu ( self ) :
        self . _call_history += [ mediator_fake . show_main_menu ]
    def show_open_menu ( self ) :
        self . _call_history += [ mediator_fake . show_open_menu ]
    def show_rename_menu ( self ) :
        self . _call_history += [ mediator_fake . show_rename_menu ]
    def show_save_as_menu ( self ) :
        self . _call_history += [ mediator_fake . show_save_as_menu ]
    def show_welcome ( self ) :
        self . _call_history += [ mediator_fake . show_welcome ]

class logic_tests :
    'logic'
    def __init__ ( self , test ) :
        self . _test = test
        self . _mediator = mediator_fake ( )
        self . _logic = logic ( self . _mediator )
    def test_copy_menu_return ( self ) :
        self . _logic . on_copy_menu_return ( )
        self . _test . assume_equal ( self . _mediator . _call_history ,
            [ mediator_fake . hide_copy_menu
            , mediator_fake . show_main_menu
            ] )
    def test_creation_menu_base_created ( self ) :
        self . _logic . on_creation_menu_base_created ( )
        self . _test . assume_equal ( self . _mediator . _call_history ,
            [ mediator_fake . hide_creation_menu
            , mediator_fake . show_welcome
            ] )
    def test_creation_menu_return ( self ) :
        self . _logic . on_creation_menu_return ( )
        self . _test . assume_equal ( self . _mediator . _call_history ,
            [ mediator_fake . hide_creation_menu
            , mediator_fake . show_main_menu
            ] )
    def test_edit_menu_continue ( self ) :
        self . _logic . on_edit_menu_continue ( )
        self . _test . assume_equal ( self . _mediator . _call_history ,
            [ mediator_fake . hide_edit_menu
            , mediator_fake . show_editor
            ] )
    def test_edit_menu_return_to_main_menu ( self ) :
        self . _logic . on_edit_menu_return_to_main_menu ( )
        self . _test . assume_equal ( self . _mediator . _call_history ,
            [ mediator_fake . hide_edit_menu
            , mediator_fake . show_main_menu
            ] )
    def test_edit_menu_save ( self ) :
        self . _logic . on_edit_menu_save ( )
        self . _test . assume_equal ( self . _mediator . _call_history ,
            [ mediator_fake . hide_edit_menu
            , mediator_fake . save_knowledge_base_in_editor
            , mediator_fake . show_editor
            ] )
    def test_edit_menu_save_as ( self ) :
        self . _logic . on_edit_menu_save_as ( )
        self . _test . assume_equal ( self . _mediator . _call_history ,
            [ mediator_fake . hide_edit_menu
            , mediator_fake . show_save_as_menu
            ] )
    def test_editor_menu_button ( self ) :
        self . _logic . on_editor_menu_button ( )
        self . _test . assume_equal ( self . _mediator . _call_history ,
            [ mediator_fake . hide_editor
            , mediator_fake . show_edit_menu
            ] )
    def test_main_menu_copy ( self ) :
        self . _logic . on_main_menu_copy ( )
        self . _test . assume_equal ( self . _mediator . _call_history , 
            [ mediator_fake . hide_main_menu 
            , mediator_fake . show_copy_menu
            ] )    
    def test_main_menu_create ( self ) :
        self . _logic . on_main_menu_create ( )
        self . _test . assume_equal ( self . _mediator . _call_history , 
            [ mediator_fake . hide_main_menu 
            , mediator_fake . show_creation_menu
            ] )    
    def test_main_menu_open ( self ) :
        self . _logic . on_main_menu_open ( )
        self . _test . assume_equal ( self . _mediator . _call_history ,
            [ mediator_fake . hide_main_menu
            , mediator_fake . show_open_menu
            ] )
    def test_main_menu_quit ( self ) :
        self . _logic . on_main_menu_quit ( )
        self . _test . assume_equal ( self . _mediator . _call_history , 
            [ mediator_fake . quit_application
            ] )
    def test_main_menu_rename ( self ) :
        self . _logic . on_main_menu_rename ( )
        self . _test . assume_equal ( self . _mediator . _call_history ,
            [ mediator_fake . hide_main_menu
            , mediator_fake . show_rename_menu
            ] )
    def test_open_menu_base_opened ( self ) :
        self . _logic . on_open_menu_base_opened ( )
        self . _test . assume_equal ( self . _mediator . _call_history ,
            [ mediator_fake . hide_open_menu
            , mediator_fake . show_editor
            ] )
    def test_open_menu_return ( self ) :
        self . _logic . on_open_menu_return ( )
        self . _test . assume_equal ( self . _mediator . _call_history ,
            [ mediator_fake . hide_open_menu
            , mediator_fake . show_main_menu
            ] )
    def test_rename_menu_return ( self ) :
        self . _logic . on_rename_menu_return ( )
        self . _test . assume_equal ( self . _mediator . _call_history ,
            [ mediator_fake . hide_rename_menu
            , mediator_fake . show_main_menu
            ] )
    def test_save_as_menu_base_saved ( self ) :
        self . _logic . on_save_as_menu_base_saved ( 'my name' )
        self . _test . assume_equal ( self . _mediator . _call_history ,
            [ mediator_fake . hide_save_as_menu
            , [ mediator_fake . save_as_knowledge_base_in_editor , 'my name' ]
            , mediator_fake . show_editor
            ] )
    def test_save_as_menu_return ( self ) :
        self . _logic . on_save_as_menu_return ( )
        self . _test . assume_equal ( self . _mediator . _call_history ,
            [ mediator_fake . hide_save_as_menu
            , mediator_fake . show_edit_menu
            ] )
    def test_start ( self ) :
        self . _logic . start ( )
        self . _test . assume_equal ( self . _mediator . _call_history , 
            [ mediator_fake . show_main_menu 
            ] )
    def test_welcome_finished ( self ) :
        self . _logic . on_welcome_finished ( )
        self . _test . assume_equal ( self . _mediator . _call_history ,
            [ mediator_fake . hide_welcome
            , mediator_fake . show_editor
            ] )
